package com.example.springdemo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
class SpringdemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringdemoApplication.class, args);
	}

	//获取全局配置中的变量
    @Value(value = "${book.author}")
    private String bookAuthor;
    @RequestMapping(value = "/",produces = "text/plain;charset=UTF-8")
    String index(){
        return bookAuthor;
    }

    Logger logger = LoggerFactory.getLogger(getClass());

    @RequestMapping(value = "/Test",produces = "text/plain;charset=UTF-8")
    public void contextLoads() {
        // 日志的级别；
        // 由低到高 trace < debug < info < warn < error
        // 可以调整需要输出的日志级别；日志只会在这个级别和以后的高级别生效
        logger.trace("这是trace日志...");
        logger.debug("这是debug日志...");
        // Springboot默认给我们使用的是info级别的，没有指定级别的就用SpringBoot默认规定的级别，root级别
        logger.info("这是info日志...");
        logger.warn("这是warn日志...");
        logger.error("这是error日志...");
    }

    @RequestMapping(value = "/Mongo",produces = "text/plain;charset=UTF-8")
    public void mongo() {

    }
}
